package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.WxPayRequest;
import cn.stylefeng.guns.modular.business.service.WxPayService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 账单管理控制器
 *
 * @author 施律名
 * @date 2022-03-16 16:44:29
 */
@RestController
@ApiResource(name = "账单管理")
public class WxPayController {

    @Resource
    private WxPayService wxPayService;

    /**
     * 添加账单
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "添加账单", path = "/wx/pay/add")
    public ResponseData add(@RequestBody @Validated(WxPayRequest.add.class) WxPayRequest wxPayRequest) {
        wxPayService.add(wxPayRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除账单
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "删除账单", path = "/wx/pay/delete")
    public ResponseData delete(@RequestBody @Validated(WxPayRequest.delete.class) WxPayRequest wxPayRequest) {
        wxPayService.del(wxPayRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑账单
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "编辑账单", path = "/wx/pay/edit")
    public ResponseData edit(@RequestBody @Validated(WxPayRequest.edit.class) WxPayRequest wxPayRequest) {
        wxPayService.edit(wxPayRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看账单详情
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "查看账单详情", path = "/wx/pay/detail")
    public ResponseData detail(@Validated(WxPayRequest.detail.class) WxPayRequest wxPayRequest) {
        return new SuccessResponseData(wxPayService.detail(wxPayRequest));
    }

    /**
     * 查询账单列表
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "获取账单列表", path = "/wx/pay/findList")
    public ResponseData list(WxPayRequest wxPayRequest) {
        return new SuccessResponseData(wxPayService.findList(wxPayRequest));
    }

    /**
     * 分页查询账单列表
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "分页查询", path = "/wx/pay/findPage")
    public ResponseData page(WxPayRequest wxPayRequest) {
        return new SuccessResponseData(wxPayService.findPage(wxPayRequest));
    }

}